/**
 * 功能描述 导航栏
 */

define(function (require, exports, module) {
	var Subnav = require("subnav");
	
    var instance = {
        initComponent: function (params, widget) {
        	var subnav=new Subnav({
        		parentNode:".J-subnav",
				model : {
					title:"入住类型收入统计",
					items : [{
			            id: "visitTime",
						tip:"时间",
						type:"daterange",
						ranges : {
					        "本年": [moment().startOf("year"), moment().endOf("days")]
						},
						defaultRange : "本年",
						handler : function(time){
							widget.get("grid").refresh(null,function(datas){
				        		 var k = 0;
				        		 for(var i in datas){
				        			k+=(datas[i].allPay == null ? 0 : datas[i].allPay);
				        		}
				        	widget.get("grid").setTitle("收入合计:" + k.toFixed(2) + "元");
				        	})
						}
			        },{
			        	id:"cancel",
        				type:"button",
        				text:"返回",
        				show:false,
        				handler: function(){
        					widget.get("subnav").hide(["cancel"]).show(["visitTime"]);
        					widget.show([".J-grid"]).hide([".J-detailgrid"]);
        					widget.get("grid").refresh();
        				}
			        }]
				}
        	});
        	widget.set("subnav",subnav);
        }
    };
    module.exports = instance;
});
